package com.xiaolin.admin.utils;

import java.util.Arrays;
import java.util.List;
import java.util.Random;

/**
 * @author xiaolin
 * @description 描述
 * @since 2024/10/23
 */
public class NameGenerator {
    // 常见姓氏列表
    private static final List<String> SURNAMES = Arrays.asList(
            "赵", "钱", "孙", "李", "周", "吴", "郑", "王", "冯", "陈",
            "褚", "卫", "蒋", "沈", "韩", "杨", "朱", "秦", "尤", "许"
    );

    // 常见名字用字列表（男性和女性名字分开）
    private static final List<String> FIRST_NAMES_MALE = Arrays.asList(
            "伟", "刚", "勇", "毅", "俊", "峰", "强", "军", "平", "保",
            "东", "文", "辉", "力", "明", "永", "健", "世", "广", "志"
    );

    private static final List<String> SECOND_NAMES_MALE = Arrays.asList(
            "义", "兴", "良", "海", "山", "仁", "波", "宁", "贵", "福",
            "生", "龙", "元", "全", "国", "胜", "学", "祥", "才", "发"
    );

    private static final List<String> FIRST_NAMES_FEMALE = Arrays.asList(
            "秀", "娟", "英", "华", "慧", "巧", "美", "娜", "静", "淑",
            "惠", "珠", "翠", "雅", "芝", "玉", "萍", "红", "娥", "玲"
    );

    private static final List<String> SECOND_NAMES_FEMALE = Arrays.asList(
            "芬", "芳", "燕", "彩", "春", "菊", "兰", "凤", "洁", "梅",
            "琳", "素", "云", "莲", "真", "环", "雪", "荣", "爱", "妹"
    );

    // 随机数生成器
    private static final Random RANDOM = new Random();

    public static String getName(boolean isMale) {
        String surname = SURNAMES.get(RANDOM.nextInt(SURNAMES.size()));
        String firstName;
        String secondName;
        if (isMale) {
            firstName = FIRST_NAMES_MALE.get(RANDOM.nextInt(FIRST_NAMES_MALE.size()));
            secondName = SECOND_NAMES_MALE.get(RANDOM.nextInt(SECOND_NAMES_MALE.size()));
        } else {
            firstName = FIRST_NAMES_FEMALE.get(RANDOM.nextInt(FIRST_NAMES_FEMALE.size()));
            secondName = SECOND_NAMES_FEMALE.get(RANDOM.nextInt(SECOND_NAMES_FEMALE.size()));
        }
        return surname + firstName + secondName;
    }
}
